package com.topdt.jbpm.web.struts.action;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.thx.common.struts2.CurdAction;
import com.thx.common.util.AppContext;
import com.thx.common.web.ActionResult;
import com.thx.log.LogUtil;
import com.topdt.jbpm.model.AppAuthority;
import com.topdt.jbpm.model.AppForm;
import com.topdt.jbpm.model.AppHandle;
import com.topdt.jbpm.model.AppType;
import com.topdt.jbpm.model.Application;
import com.topdt.jbpm.model.ArcTemplate;
import com.topdt.jbpm.model.Control;
import com.topdt.jbpm.model.Field;
import com.topdt.jbpm.model.Flow;
import com.topdt.jbpm.model.FlowDetail;
import com.topdt.jbpm.model.Form;
import com.topdt.jbpm.service.AppAuthorityService;
import com.topdt.jbpm.service.AppTypeService;
import com.topdt.jbpm.service.AppFormService;
import com.topdt.jbpm.service.AppHandleService;
import com.topdt.jbpm.service.ApplicationService;
import com.topdt.jbpm.service.ArcTemplateService;
import com.topdt.jbpm.service.ControlService;
import com.topdt.jbpm.service.FieldService;
import com.topdt.jbpm.service.FlowDetailService;
import com.topdt.jbpm.service.FlowService;
import com.topdt.jbpm.service.FormService;
import com.topdt.jbpm.utils.ModuleConstant;

@Namespace("/workflow")
@Action(value = "appConfig",
		results = {
		@Result(name = "list",location = "/workflow/app/list.jsp"),
		@Result(name = "input",location = "/workflow/app/app-custom.jsp"),
		@Result(name = "baseInfo",location = "/workflow/app/base-info.jsp"),
		@Result(name = "copy",location = "/workflow/app/copy.jsp"),
		@Result(name = "jsonStr", type = "json", params = { "root", "jsonStr" }),
		@Result(name = "json", type = "json", params = { "root", "result" })
		}
)
@Controller
@Scope("prototype")
public class AppConfigAction extends CurdAction<Application> {

	private static final long serialVersionUID = 1L;

	@Autowired
	private ApplicationService applicationService;
	@Autowired
	private AppTypeService appTypeService;
	@Autowired
	private FlowService flowService;
	@Autowired
	private FlowDetailService flowDetailService;
	@Autowired
	private AppAuthorityService appAuthorityService;
	@Autowired
	private FormService formService;
	@Autowired
	private FieldService fieldManager;
	@Autowired
	private AppHandleService appHandleService;
	@Autowired
	private AppFormService appFormService;
	@Autowired
	private ControlService controlService;
	@Autowired
	private ArcTemplateService arcTemplateService;

	private AppAuthority perAuthority;
	private AppAuthority roleAuthority;
	private AppAuthority deptAuthority;
	private List<AppType> appTypeList;
	private List<Flow> flowList;
	private String applicationId;
	private List<AppForm> appFormList;
	private List<AppHandle> appHandleList;
	private List<ArcTemplate> tempList;
	private List<String> stage = new ArrayList<String>();
	private String jsonStr;
	private String[] appIds;//fengjinshou 20151229 应用id
	private Long[] appOrders;//fengjinshou 20151229 应用排序
	
	/**
	 * 进入基本信息维护页面
	 * 
	 * @author Xuejw 2016年10月8日 下午5:32:17
	 * @return
	 */
	public String toBaseInfo(){
	  if (StringUtils.isNotBlank(id)) {
        entity = applicationService.get(id);
        if (entity == null) {
            setResult(ActionResult.FAIL, "要修改的记录不存在！！！");
        }
      }else{
          entity = new Application();
          entity.setAppAttr("0");
      }
	  
	  appTypeList = appTypeService.getAllFillSelect();
      flowList = flowService.getAllFillSelect();
      appFormList = appFormService.getAll();
      appHandleList = appHandleService.getAll();
      tempList = arcTemplateService.find();
      if(flowList!=null){
        for (Flow temp : flowList) {
          List<FlowDetail> flowDetails = flowDetailService.findByFlowId(temp.getFlowId());
          temp.setFlowDetails(flowDetails);
        }
      }
      getAppAuth();
	  return "baseInfo";
	}

	@Override
	protected void doList() throws Exception {
		logger.debug("<进入>:doList方法");
		list = applicationService.getAppsPageByComId(entity.getAppName());
	}
   /**
    *
   * @author _zili
   * @Description:doDelete
   * @date 2015年3月30日 下午3:57:26
    */
	@Override
	protected void doDelete() throws Exception {
		logger.debug("<进入>:doDelete方法");
		if (StringUtils.isNotBlank(id)) {
			entity = applicationService.get(id);
			if(Application.SYSTEM_APP.equals(entity.getIsInherent())){
				setResult(ActionResult.FAIL, "系统应用，无法删除！");
			}else{
				entity.setIsValid(Application.INVALID_APP);
				applicationService.save(entity);
				setResult(ActionResult.SUCCESS, "删除成功！");
			}
			LogUtil.log(ModuleConstant.APP_CONFIG, LogUtil.ACTION_DELETE, LogUtil.RESULT_SUCCESS, "删除应用定制");
		} else {
			setResult(ActionResult.FAIL, "服务器异常！");
		}
	}
	@Override
	protected void doInput() throws Exception {
		logger.debug("<进入>:doInput方法");
		if (StringUtils.isNotBlank(id)) {
			entity = applicationService.get(id);
			if (entity == null) {
				setResult(ActionResult.FAIL, "要修改的记录不存在！！！");
			}
		}else{
			entity = new Application();
			entity.setAppAttr("0");
		}
		appTypeList = appTypeService.getAllFillSelect();
	    flowList = flowService.getAllFillSelect();
	    appFormList = appFormService.getAll();
	    appHandleList = appHandleService.getAll();
	    tempList = arcTemplateService.find();
	    if(flowList!=null)
    		for (Flow temp : flowList) {
    			List<FlowDetail> flowDetails = flowDetailService.findByFlowId(temp.getFlowId());
    			temp.setFlowDetails(flowDetails);
    		}
		getAppAuth();
	}
	/**
	 *
	* @author _zili
	* @Description:用于页面显示已有的权限
	* @date 2015年3月27日 下午5:45:01
	 */
	public void getAppAuth(){
		logger.debug("<进入>:getAppAuth方法");
		List<AppAuthority> list = appAuthorityService.findByAppId(id);
		for(int i = 0;i<list.size();i++){
			if(AppAuthority.TYPE_ROLE.equals(list.get(i).getAuthorityType())){
				roleAuthority = list.get(i);
			}else if(AppAuthority.TYPE_DEPT.equals(list.get(i).getAuthorityType())){
				deptAuthority = list.get(i);
			}else if(AppAuthority.TYPE_PER.equals(list.get(i).getAuthorityType())){
				perAuthority = list.get(i);
			}
		}
	}
	/**
	 *
	* @author _zili
	* @Description:应用的保存方法
	* @date 2015年3月31日 上午11:32:04
	 */
	@Override
	protected void doSave() throws Exception {
		logger.debug("<进入>:doSave方法");
		try {
			String comId = AppContext.getCurrentComId();
			String jsonRes = "";
			//外置表单、外置公文、外置表单和意见、外置公文和意见
//			if(entity.getAppAttr().equals(Application.APPATTR_CUSTOM_FORM)
//					|| entity.getAppAttr().equals(Application.APPATTR_CUSTOM_DOC)
//					|| entity.getAppAttr().equals(Application.APPATTR_CUSTOM_FORM_OPINION)
//					|| entity.getAppAttr().equals(Application.APPATTR_CUSTOM_DOC_OPINION)){
//				entity.setAppForm(appFormService.get(entity.getAppForm().getAppFormId()));
//			}else{
				entity.setAppForm(null);
//			}
              entity.setHandle(appHandleService.getById(entity.getHandle().getHandleId()));
			if (StringUtils.isBlank(id)) {
				entity.setCompanyId(comId);
				entity.setForm(saveForm(comId));
				entity.setCreateTime(new Date());
				entity.setIsComplete("0");
				FlowDetail detail = flowDetailService.getDetailByJbpmflowId(entity.getFlowId());
				if(detail!=null){
				  entity.setFlowKey(detail.getJbpmFlowKey());
				}
				applicationService.save(entity);
			} else {
				Application app = applicationService.get(id);
				jsonRes = judgeFlowChanged(app);
				app.setAppName(entity.getAppName());
				app.setAppDescribe(entity.getAppDescribe());
				app.setAppAttr(entity.getAppAttr());
				app.setAppType(appTypeService.get(entity.getAppType().getTypeId()));
				app.setFlowId(entity.getFlowId());
				app.setForm(saveForm(comId));
				app.setDocTempath(entity.getDocTempath());
				app.setHandle(entity.getHandle());
				app.setAppForm(entity.getAppForm());
				app.setSelectFlowId(entity.getSelectFlowId());
				FlowDetail detail = flowDetailService.getDetailByJbpmflowId(entity.getFlowId());
				if(detail!=null){
				  app.setFlowKey(detail.getJbpmFlowKey());
				}
				applicationService.save(app);
			}
			appAuthorityService.deleteByAppId(id);
			saveAppAuth(comId);
			String tip = StringUtils.isBlank(id)?"添加成功":"修改成功"+jsonRes;
			setResult(ActionResult.SUCCESS,tip);
			result.setVal("appId", StringUtils.isBlank(id)?entity.getAppId():id); 
			LogUtil.log(ModuleConstant.APP_CONFIG, StringUtils.isBlank(id)?LogUtil.ACTION_ADD:LogUtil.ACTION_UPDATE, LogUtil.RESULT_SUCCESS, "应用类型维护"+entity.getAppId());
		} catch (Exception e) {
			if (StringUtils.isBlank(id)) {
				setResult(ActionResult.FAIL, "添加失败！");
			} else {
				setResult(ActionResult.FAIL, "修改失败！");
			}
			logger.error("<错误>:"+e.getMessage(),e);
		}

	}
	/**
	 *
	* @author _zili
	* @Description:判断流程是否改变，改变，则把原control数据删除。
	* @date 2015年5月13日 上午9:10:35
	 */
	public String  judgeFlowChanged(Application app){
		logger.debug("<进入>:judgeFlowChanged方法");
		String result = "";
		if(StringUtils.isNotBlank(app.getFlowId())&&StringUtils.isNotBlank(entity.getFlowId())){
			if(!(app.getFlowId().equals(entity.getFlowId()))){
				Object[] objs = new Object[] { app.getAppId(), app.getFlowId(), app.getForm().getFormId() };
				List<Control> listControl = controlService.findControlByObjects(objs);
				if(listControl!=null&&listControl.size()>0){
                    app.setIsComplete("0");
					result = ",需要重新执行'字段读写性'和'流程环节操作权限'操作!";
				}
			}
		}
		return result;
	}
	/**
	 *
	* @author _zili
	* @Description:先保存form实体
	* @date 2015年4月1日 上午9:38:56
	 */
	public Form saveForm (String comId){
		logger.debug("<进入>:saveForm方法");
		Form f;
		if(StringUtils.isBlank(id)){
			f = new Form();
		}else{
			Application app = applicationService.get(id);
			f = app.getForm();
		}
		//--先保存form实体
		f.setCompanyId(comId);
		f.setFormName(entity.getAppName());
		if(entity.getAppAttr().equals(Application.APPATTR_CUSTOM_FORM)
				|| entity.getAppAttr().equals(Application.APPATTR_CUSTOM_FORM_OPINION)
				|| entity.getAppAttr().equals(Application.APPATTR_CUSTOM_DOC)
				|| entity.getAppAttr().equals(Application.APPATTR_CUSTOM_DOC_OPINION)){

			f.setTempletStorageType(Form.TempletStorageType_FILE);
	    } else {
	    	f.setTempletStorageType(Form.TempletStorageType_BYTE);
	    }
		formService.save(f);
		return f;
	}
	/**
	 *
	* @author _zili
	* @Description:保存应用的角色、部门、人员使用权限
	* @date 2015年3月27日 下午5:34:10
	 */
	public void  saveAppAuth(String comId){
		logger.debug("<进入>:saveAppAuth方法");
		String appId = StringUtils.isNotBlank(id)?id:entity.getAppId();
		if(roleAuthority!=null&&StringUtils.isNotBlank(roleAuthority.getAuthorityDataName())){
			roleAuthority.setAppId(appId);
			roleAuthority.setCompanyId(comId);
			appAuthorityService.save(roleAuthority);
		}
		if(deptAuthority!=null&&StringUtils.isNotBlank(deptAuthority.getAuthorityDataName())){
			deptAuthority.setAppId(appId);
			deptAuthority.setCompanyId(comId);
			appAuthorityService.save(deptAuthority);
		}
		if(perAuthority!=null&&StringUtils.isNotBlank(perAuthority.getAuthorityDataName())){
			perAuthority.setAppId(appId);
			perAuthority.setCompanyId(comId);
			appAuthorityService.save(perAuthority);
		}

	}
	/**
	 *
	* @author _zili
	* @Description:根据流程key查询流程的版本
	* @date 2015年3月25日 下午5:03:05
	 */
	public void findVersion(){
		logger.debug("<进入>:findVersion方法   根据流程key查询流程的版本");
		StringBuffer sbuffer = new StringBuffer();
		if(StringUtils.isNotBlank(entity.getSelectFlowId())){
			List<FlowDetail> listFlowDetail = flowDetailService.getVersionByFlowId(entity.getSelectFlowId());
			if(listFlowDetail!=null && listFlowDetail.size()>0){
				for(int i = 0; i<listFlowDetail.size(); i++){
					sbuffer.append("<option value=\""+listFlowDetail.get(i).getJbpmFlowId()+"\">"+listFlowDetail.get(i).getVersion()+"</option>");
				}
			}
		}else{
			sbuffer.append("<option value=\"\">无版本号</option>");
		}
		try {
			writeJson(sbuffer.toString());
		} catch (IOException e) {
			logger.error("<错误>:根据流程key查询流程的版本失败",e);
		}
	}
	/**
	 *
	* @author _zili
	* @Description:验证app名称的唯一性
	* @date 2015年3月26日 上午8:58:55
	 */
	public void checkAppName(){
		logger.debug("<进入>:checkAppName方法   验证app名称的唯一性");
		String comId = AppContext.getCurrentComId();
		Application app = null;
		try {
			app =  applicationService.getAppName(entity.getAppName(),comId);
			if(app==null){
				writeJson("true");
			}else{
				if(app.getAppId().equals(id)){
					writeJson("true");
				}else{
					writeJson("false");
				}
			}

		} catch (Exception e) {
			setResult(ActionResult.FAIL, "服务器异常！");
			logger.error("<错误>:验证app名称的唯一性失败",e);
		}
	}
	/**
	 *
	* @author _zili
	* @Description:复制app
	* @date 2015年3月31日 上午10:08:59
	 */
	public String copyApp(){
		logger.debug("<进入>:copyApp方法");
		Application application = applicationService.get(applicationId);
		//复制form实体
		Form form = new Form();
		form.setCompanyId(application.getForm().getCompanyId());
		form.setFormName(application.getForm().getFormName());
		form.setMobileTemplateByte(application.getForm().getMobileTemplateByte());
		form.setTempletByte(application.getForm().getTempletByte());
		form.setTempletPath(application.getForm().getTempletPath());
		form.setTempletStorageType(application.getForm().getTempletStorageType());
		formService.save(form);
		//复制application实体
		entity.setAppType(application.getAppType());
		entity.setForm(form);
		entity.setHandle(application.getHandle());
		entity.setCompanyId(application.getCompanyId());
		entity.setIsInherent(Application.NORMAL_APP);
		entity.setIsValid(application.getIsValid());
		entity.setAppAttr(application.getAppAttr());
		entity.setDocTempath(application.getDocTempath());
		entity.setFlowId(application.getFlowId());
		entity.setFlowKey(application.getFlowKey());
		entity.setCreateTime(new Date());
		entity.setAppForm(application.getAppForm());
		entity.setSelectFlowId(application.getSelectFlowId());
		entity.setIsComplete(application.getIsComplete());
		entity.setAppOrder(application.getAppOrder());


		applicationService.save(entity);
		//复制权限
		copyAuth(applicationId,entity.getAppId());
		copyControl(applicationId,entity.getAppId(),form.getFormId());
		//复制field实体
		List<Field> fieldList = fieldManager.getFieldByFormId(application.getForm().getFormId());
		for(Field field:fieldList){
			Field newField = new Field();
			newField.setCompanyId(field.getCompanyId());
			newField.setDefaultValue(field.getDefaultValue());
			newField.setFieldLength(field.getFieldLength());
			newField.setFieldName(field.getFieldName());
			newField.setFieldOption(field.getFieldOption());
			newField.setFieldText(field.getFieldText());
			newField.setFieldType(field.getFieldType());
			newField.setIsNecessary(field.getIsNecessary());
			newField.setIsShow(field.getIsShow());
			newField.setSeqenceNum(field.getSeqenceNum());
			newField.setFormId(form.getFormId());
			fieldManager.save(newField);
		}
		setResult(ActionResult.SUCCESS,"复制成功！");
		LogUtil.log(ModuleConstant.APP_CONFIG, "复制应用", LogUtil.RESULT_SUCCESS, "复制应用");
		return JSON;
	}
	/**
	 *
	* @author _zili
	* @Description:复制使用人员、部门、角色权限
	* @date 2015年4月1日 上午10:21:45
	 */
	public void copyAuth(String srcId,String destId){
		logger.debug("<进入>:copyAuth方法");
		List<AppAuthority> list = appAuthorityService.findByAppId(srcId);
		for(AppAuthority auth:list){
			AppAuthority newAuth = new AppAuthority();
			newAuth.setCompanyId(auth.getCompanyId());
			newAuth.setAuthorityData(auth.getAuthorityData());
			newAuth.setAuthorityDataName(auth.getAuthorityDataName());
			newAuth.setAuthorityType(auth.getAuthorityType());
			newAuth.setAppId(destId);
			appAuthorityService.save(newAuth);
		}
	}
	/**
	 *
	* @author _zili
	* @Description:复制字段读写性等权限
	* @date 2015年4月29日 下午3:50:12
	 */
	public void copyControl(String srcId,String destId,String formId){
		logger.debug("<进入>:copyControl方法");
		Application application = applicationService.findById(srcId);
		if(application!=null&&application.getForm()!=null){
			Object[] objs = new Object[] { srcId, application.getFlowId(), application.getForm().getFormId() };
			List<Control> listControl = controlService.findControlByObjects(objs);
			for(Control c:listControl){
				Control newControl = new Control();
				newControl.setActivityName(c.getActivityName());
				newControl.setAppId(destId);
				newControl.setCompanyId(c.getCompanyId());
				newControl.setDefaultOption(c.getDefaultOption());
				newControl.setFlowId(c.getFlowId());
				newControl.setFieldControl(c.getFieldControl());
				newControl.setFormId(formId);
				newControl.setFunctionControl(c.getFunctionControl());
				newControl.setRemindControl(c.getRemindControl());
				newControl.setOpinionName(c.getOpinionName());
				controlService.save(newControl);
			}
		}

	}
	/**
	 *
	* @author _zili
	* @Description:判断是否有字段以及是否有流程操作权限
	* @date 2015年4月20日 上午8:58:41
	* 
	* 1.字段管理             只有有了基本信息和不是外置类应用时才需填写
	* 2.表单模板             只有有了基本信息和字段管理且不是外置类应用时才需填写
	* 3.字段读写性设置  只有有了基本信息且有了流程且（有了字段或者表单是外置表单）
	* 4.流程操作权限      只有有了基本信息且有了流程且（有了字段或者表单是外置表单）且有了字段读写性数据
	*/
	public String getTabAuth(){
		logger.debug("<进入>:getTabAuth方法");
		String appId = getRequest().getParameter("appId");
		Application application = applicationService.findById(appId);
		if(application!=null){
		    //字段管理 
		    if(Application.APPATTR_FORM.equals(application.getAppAttr())||Application.APPATTR_DOC.equals(application.getAppAttr())){
		      stage.add("1");
		    }else{
		      stage.add("0");
		    }
		    //表单模板
		    if(application.getForm()!=null){
		      List<Field> fList = fieldManager.getFieldsByformId(application.getForm().getFormId());
		      if(fList!=null&&fList.size()>0&&(Application.APPATTR_FORM.equals(application.getAppAttr())||Application.APPATTR_DOC.equals(application.getAppAttr()))){//是否有字段
		        stage.add("1");
		      }else{
		        stage.add("0");
		      }
		    }else{
		      stage.add("0");
		    }
		    //字段读写性
		    if(StringUtils.isNotBlank(application.getFlowId())){
		      //有了字段或者表单是外置表单
		      List<Field> fList = fieldManager.getFieldsByformId(application.getForm().getFormId());
              if(fList!=null&&fList.size()>0){
                stage.add("1");
                stage.add("1");
              }else if(application.getAppAttr().equals(Application.APPATTR_CUSTOM_FORM)
                  || application.getAppAttr().equals(Application.APPATTR_CUSTOM_FORM_OPINION)
                  || application.getAppAttr().equals(Application.APPATTR_CUSTOM_DOC)
                  || application.getAppAttr().equals(Application.APPATTR_CUSTOM_DOC_OPINION)){
                stage.add("1");
                stage.add("1");
              }else{
                stage.add("0");
                stage.add("0");
              }
		    }else{
		      stage.add("0");
		      stage.add("0");
		    }
		}
		jsonStr = com.alibaba.fastjson.JSON.toJSONString(stage);
		return "jsonStr";
	}


	/**
	 * 保存应用的显示顺序
	 * @author 冯晋首
	 * @date   2015年12月29日 下午5:50:52
	 */
	public void saveAppOrder(){
		logger.debug("<进入>:saveAppOrder方法    保存应用的显示顺序");
		if(appIds!=null && appIds.length>0){
			try {
				for(int i=0; i<appIds.length; i++){
					Application app = applicationService.get(appIds[i]);
					if(app!=null){
						app.setAppOrder(appOrders[i]);
						applicationService.saveOrUpdate(app);
					}
				}
				writeJson("success");
			} catch (IOException e) {
				try {
					writeJson("fail");
				} catch (IOException e1) {
					logger.error("<错误>: 保存应用的显示顺序失败",e);
				}
				logger.error("<错误>: 保存应用的显示顺序失败",e);
			}
		}
	}

	public String toCopy(){
		logger.info(applicationId);
		return "copy";
	}
	public AppAuthority getPerAuthority() {
		return perAuthority;
	}

	public void setPerAuthority(AppAuthority perAuthority) {
		this.perAuthority = perAuthority;
	}

	public AppAuthority getRoleAuthority() {
		return roleAuthority;
	}

	public void setRoleAuthority(AppAuthority roleAuthority) {
		this.roleAuthority = roleAuthority;
	}

	public AppAuthority getDeptAuthority() {
		return deptAuthority;
	}

	public void setDeptAuthority(AppAuthority deptAuthority) {
		this.deptAuthority = deptAuthority;
	}

	public List<AppType> getAppTypeList() {
		return appTypeList;
	}

	public void setAppTypeList(List<AppType> appTypeList) {
		this.appTypeList = appTypeList;
	}

	public List<Flow> getFlowList() {
		return flowList;
	}

	public void setFlowList(List<Flow> flowList) {
		this.flowList = flowList;
	}
	public String getApplicationId() {
		return applicationId;
	}
	public void setApplicationId(String applicationId) {
		this.applicationId = applicationId;
	}
	public List<AppForm> getAppFormList() {
		return appFormList;
	}
	public void setAppFormList(List<AppForm> appFormList) {
		this.appFormList = appFormList;
	}
	public List<AppHandle> getAppHandleList() {
		return appHandleList;
	}
	public void setAppHandleList(List<AppHandle> appHandleList) {
		this.appHandleList = appHandleList;
	}

	public List<String> getStage() {
		return stage;
	}
	public void setStage(List<String> stage) {
		this.stage = stage;
	}
	public String getJsonStr() {
		return jsonStr;
	}
	public void setJsonStr(String jsonStr) {
		this.jsonStr = jsonStr;
	}
	public List<ArcTemplate> getTempList() {
		return tempList;
	}
	public void setTempList(List<ArcTemplate> tempList) {
		this.tempList = tempList;
	}
	public String[] getAppIds() {
		return appIds;
	}
	public void setAppIds(String[] appIds) {
		this.appIds = appIds;
	}
	public Long[] getAppOrders() {
		return appOrders;
	}
	public void setAppOrders(Long[] appOrders) {
		this.appOrders = appOrders;
	}

}
